\(\int \cot ^2(a+i \log (x)) \, dx\) [197]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 11, antiderivative size = 48 \[ \int \cot ^2(a+i \log (x)) \, dx=-x-\frac {2 e^{2 i a} x}{e^{2 i a}-x^2}+2 e^{i a} \text {arctanh}\left (e^{-i a} x\right ) \]

[Out]

-x-2*exp(2*I*a)*x/(exp(2*I*a)-x^2)+2*exp(I*a)*arctanh(x/exp(I*a))

Rubi [A] (verified)

Time = 0.05 (sec) , antiderivative size = 48, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.455, Rules used = {4588, 381, 398, 294, 213} \[ \int \cot ^2(a+i \log (x)) \, dx=2 e^{i a} \text {arctanh}\left (e^{-i a} x\right )-\frac {2 e^{2 i a} x}{-x^2+e^{2 i a}}-x \]

[In]

Int[Cot[a + I*Log[x]]^2,x]

[Out]

-x - (2*E^((2*I)*a)*x)/(E^((2*I)*a) - x^2) + 2*E^(I*a)*ArcTanh[x/E^(I*a)]

Rule 213

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(-(Rt[-a, 2]*Rt[b, 2])^(-1))*ArcTanh[Rt[b, 2]*(x/Rt[-a, 2])]
, x] /; FreeQ[{a, b}, x] && NegQ[a/b] && (LtQ[a, 0] || GtQ[b, 0])

Rule 294

Int[((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[c^(n - 1)*(c*x)^(m - n + 1)*((a + b*x^
n)^(p + 1)/(b*n*(p + 1))), x] - Dist[c^n*((m - n + 1)/(b*n*(p + 1))), Int[(c*x)^(m - n)*(a + b*x^n)^(p + 1), x
], x] /; FreeQ[{a, b, c}, x] && IGtQ[n, 0] && LtQ[p, -1] && GtQ[m + 1, n] &&  !ILtQ[(m + n*(p + 1) + 1)/n, 0]
&& IntBinomialQ[a, b, c, n, m, p, x]

Rule 381

Int[((a_) + (b_.)*(x_)^(n_))^(p_.)*((c_) + (d_.)*(x_)^(n_))^(q_.), x_Symbol] :> Int[x^(n*(p + q))*(b + a/x^n)^
p*(d + c/x^n)^q, x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[b*c - a*d, 0] && IntegersQ[p, q] && NegQ[n]

Rule 398

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Int[PolynomialDivide[(a + b*x^n)
^p, (c + d*x^n)^(-q), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && IGtQ[p, 0] && ILt
Q[q, 0] && GeQ[p, -q]

Rule 4588

Int[Cot[((a_.) + Log[x_]*(b_.))*(d_.)]^(p_.), x_Symbol] :> Int[((-I - I*E^(2*I*a*d)*x^(2*I*b*d))/(1 - E^(2*I*a
*d)*x^(2*I*b*d)))^p, x] /; FreeQ[{a, b, d, p}, x]

Rubi steps \begin{align*} \text {integral}& = \int \frac {\left (-i-\frac {i e^{2 i a}}{x^2}\right )^2}{\left (1-\frac {e^{2 i a}}{x^2}\right )^2} \, dx \\ & = \int \frac {\left (-i e^{2 i a}-i x^2\right )^2}{\left (-e^{2 i a}+x^2\right )^2} \, dx \\ & = \int \left (-1-\frac {4 e^{2 i a} x^2}{\left (-e^{2 i a}+x^2\right )^2}\right ) \, dx \\ & = -x-\left (4 e^{2 i a}\right ) \int \frac {x^2}{\left (-e^{2 i a}+x^2\right )^2} \, dx \\ & = -x-\frac {2 e^{2 i a} x}{e^{2 i a}-x^2}-\left (2 e^{2 i a}\right ) \int \frac {1}{-e^{2 i a}+x^2} \, dx \\ & = -x-\frac {2 e^{2 i a} x}{e^{2 i a}-x^2}+2 e^{i a} \text {arctanh}\left (e^{-i a} x\right ) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.06 (sec) , antiderivative size = 70, normalized size of antiderivative = 1.46 \[ \int \cot ^2(a+i \log (x)) \, dx=2 \text {arctanh}(x (\cos (a)-i \sin (a))) (\cos (a)+i \sin (a))+\frac {-x \left (-3+x^2\right ) \cos (a)+i x \left (3+x^2\right ) \sin (a)}{\left (-1+x^2\right ) \cos (a)-i \left (1+x^2\right ) \sin (a)} \]

[In]

Integrate[Cot[a + I*Log[x]]^2,x]

[Out]

2*ArcTanh[x*(Cos[a] - I*Sin[a])]*(Cos[a] + I*Sin[a]) + (-(x*(-3 + x^2)*Cos[a]) + I*x*(3 + x^2)*Sin[a])/((-1 +
x^2)*Cos[a] - I*(1 + x^2)*Sin[a])

Maple [A] (verified)

Time = 1.36 (sec) , antiderivative size = 36, normalized size of antiderivative = 0.75

method result size
risch \(-3 x -\frac {2 x}{\frac {{\mathrm e}^{2 i a}}{x^{2}}-1}+2 \,\operatorname {arctanh}\left (x \,{\mathrm e}^{-i a}\right ) {\mathrm e}^{i a}\) \(36\)

[In]

int(cot(a+I*ln(x))^2,x,method=_RETURNVERBOSE)

[Out]

-3*x-2*x/(exp(2*I*a)/x^2-1)+2*arctanh(x*exp(-I*a))*exp(I*a)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 72, normalized size of antiderivative = 1.50 \[ \int \cot ^2(a+i \log (x)) \, dx=-\frac {x^{3} - {\left (x^{2} - e^{\left (2 i \, a\right )}\right )} e^{\left (i \, a\right )} \log \left (x + e^{\left (i \, a\right )}\right ) + {\left (x^{2} - e^{\left (2 i \, a\right )}\right )} e^{\left (i \, a\right )} \log \left (x - e^{\left (i \, a\right )}\right ) - 3 \, x e^{\left (2 i \, a\right )}}{x^{2} - e^{\left (2 i \, a\right )}} \]

[In]

integrate(cot(a+I*log(x))^2,x, algorithm="fricas")

[Out]

-(x^3 - (x^2 - e^(2*I*a))*e^(I*a)*log(x + e^(I*a)) + (x^2 - e^(2*I*a))*e^(I*a)*log(x - e^(I*a)) - 3*x*e^(2*I*a
))/(x^2 - e^(2*I*a))

Sympy [A] (verification not implemented)

Time = 0.16 (sec) , antiderivative size = 42, normalized size of antiderivative = 0.88 \[ \int \cot ^2(a+i \log (x)) \, dx=- x + \frac {2 x e^{2 i a}}{x^{2} - e^{2 i a}} - \left (\log {\left (x - e^{i a} \right )} - \log {\left (x + e^{i a} \right )}\right ) e^{i a} \]

[In]

integrate(cot(a+I*ln(x))**2,x)

[Out]

-x + 2*x*exp(2*I*a)/(x**2 - exp(2*I*a)) - (log(x - exp(I*a)) - log(x + exp(I*a)))*exp(I*a)

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 270 vs. \(2 (36) = 72\).

Time = 0.22 (sec) , antiderivative size = 270, normalized size of antiderivative = 5.62 \[ \int \cot ^2(a+i \log (x)) \, dx=-\frac {2 \, {\left ({\left (-i \, \cos \left (a\right ) + \sin \left (a\right )\right )} \arctan \left (\sin \left (a\right ), x + \cos \left (a\right )\right ) + {\left (-i \, \cos \left (a\right ) + \sin \left (a\right )\right )} \arctan \left (\sin \left (a\right ), x - \cos \left (a\right )\right )\right )} x^{2} + 2 \, x^{3} - 6 \, x {\left (\cos \left (2 \, a\right ) + i \, \sin \left (2 \, a\right )\right )} + 2 \, {\left ({\left (i \, \cos \left (a\right ) - \sin \left (a\right )\right )} \cos \left (2 \, a\right ) - {\left (\cos \left (a\right ) + i \, \sin \left (a\right )\right )} \sin \left (2 \, a\right )\right )} \arctan \left (\sin \left (a\right ), x + \cos \left (a\right )\right ) + 2 \, {\left ({\left (i \, \cos \left (a\right ) - \sin \left (a\right )\right )} \cos \left (2 \, a\right ) - {\left (\cos \left (a\right ) + i \, \sin \left (a\right )\right )} \sin \left (2 \, a\right )\right )} \arctan \left (\sin \left (a\right ), x - \cos \left (a\right )\right ) - {\left (x^{2} {\left (\cos \left (a\right ) + i \, \sin \left (a\right )\right )} - {\left (\cos \left (a\right ) + i \, \sin \left (a\right )\right )} \cos \left (2 \, a\right ) + {\left (-i \, \cos \left (a\right ) + \sin \left (a\right )\right )} \sin \left (2 \, a\right )\right )} \log \left (x^{2} + 2 \, x \cos \left (a\right ) + \cos \left (a\right )^{2} + \sin \left (a\right )^{2}\right ) + {\left (x^{2} {\left (\cos \left (a\right ) + i \, \sin \left (a\right )\right )} - {\left (\cos \left (a\right ) + i \, \sin \left (a\right )\right )} \cos \left (2 \, a\right ) - {\left (i \, \cos \left (a\right ) - \sin \left (a\right )\right )} \sin \left (2 \, a\right )\right )} \log \left (x^{2} - 2 \, x \cos \left (a\right ) + \cos \left (a\right )^{2} + \sin \left (a\right )^{2}\right )}{2 \, {\left (x^{2} - \cos \left (2 \, a\right ) - i \, \sin \left (2 \, a\right )\right )}} \]

[In]

integrate(cot(a+I*log(x))^2,x, algorithm="maxima")

[Out]

-1/2*(2*((-I*cos(a) + sin(a))*arctan2(sin(a), x + cos(a)) + (-I*cos(a) + sin(a))*arctan2(sin(a), x - cos(a)))*
x^2 + 2*x^3 - 6*x*(cos(2*a) + I*sin(2*a)) + 2*((I*cos(a) - sin(a))*cos(2*a) - (cos(a) + I*sin(a))*sin(2*a))*ar
ctan2(sin(a), x + cos(a)) + 2*((I*cos(a) - sin(a))*cos(2*a) - (cos(a) + I*sin(a))*sin(2*a))*arctan2(sin(a), x
- cos(a)) - (x^2*(cos(a) + I*sin(a)) - (cos(a) + I*sin(a))*cos(2*a) + (-I*cos(a) + sin(a))*sin(2*a))*log(x^2 +
 2*x*cos(a) + cos(a)^2 + sin(a)^2) + (x^2*(cos(a) + I*sin(a)) - (cos(a) + I*sin(a))*cos(2*a) - (I*cos(a) - sin
(a))*sin(2*a))*log(x^2 - 2*x*cos(a) + cos(a)^2 + sin(a)^2))/(x^2 - cos(2*a) - I*sin(2*a))

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 79 vs. \(2 (36) = 72\).

Time = 0.29 (sec) , antiderivative size = 79, normalized size of antiderivative = 1.65 \[ \int \cot ^2(a+i \log (x)) \, dx=-\frac {x^{3}}{x^{2} - e^{\left (2 i \, a\right )}} - 2 \, {\left (\frac {\arctan \left (\frac {x}{\sqrt {-e^{\left (2 i \, a\right )}}}\right )}{\sqrt {-e^{\left (2 i \, a\right )}}} - \frac {x}{x^{2} - e^{\left (2 i \, a\right )}}\right )} e^{\left (2 i \, a\right )} + \frac {5 \, x e^{\left (2 i \, a\right )}}{x^{2} - e^{\left (2 i \, a\right )}} \]

[In]

integrate(cot(a+I*log(x))^2,x, algorithm="giac")

[Out]

-x^3/(x^2 - e^(2*I*a)) - 2*(arctan(x/sqrt(-e^(2*I*a)))/sqrt(-e^(2*I*a)) - x/(x^2 - e^(2*I*a)))*e^(2*I*a) + 5*x
*e^(2*I*a)/(x^2 - e^(2*I*a))

Mupad [B] (verification not implemented)

Time = 26.48 (sec) , antiderivative size = 44, normalized size of antiderivative = 0.92 \[ \int \cot ^2(a+i \log (x)) \, dx=-x+2\,\sqrt {{\mathrm {e}}^{a\,2{}\mathrm {i}}}\,\mathrm {atanh}\left (\frac {x}{\sqrt {{\mathrm {e}}^{a\,2{}\mathrm {i}}}}\right )-\frac {2\,x\,{\mathrm {e}}^{a\,2{}\mathrm {i}}}{{\mathrm {e}}^{a\,2{}\mathrm {i}}-x^2} \]

[In]

int(cot(a + log(x)*1i)^2,x)

[Out]

2*exp(a*2i)^(1/2)*atanh(x/exp(a*2i)^(1/2)) - x - (2*x*exp(a*2i))/(exp(a*2i) - x^2)